﻿@model ProfileEditModel

<div class="panel-body  ">
    <div class="col-xs-11">
        @using (Html.BeginForm("ChangePassword", "UserSpace", FormMethod.Post, new { @id = "ChangePasswordForm", @class = " form-horizontal tn-form-validation " }))
        {
            @Html.AntiForgeryToken()
            <div class="form-group " id="passwordLoad">
                @Html.Action("_PassWordPoclaimed", "Account", new { passWordTitle = "原密码" })
                <span style="top:25px" class="glyphicon  form-control-feedback" aria-hidden="true"><i class="fa fa-eye-slash"></i></span>
                <input class="tn-click-eye" type="button" />
                @Html.ValidationMessageFor(n => n.PassWord)

                <span class="help-block tn-mb-0">字母、数字至少6位</span>
            </div>

            <div class="form-group " id="newPasswordLoad">
                @Html.Action("_PassWordPoclaimed", "Account", new { name = "NewPassword", passWordTitle = "新密码" })
                <span style="top:25px" class="glyphicon  form-control-feedback" aria-hidden="true"><i class="fa fa-eye-slash"></i></span>
                <input class="tn-click-eye" type="button" />
                @Html.ValidationMessageFor(n => n.NewPassword)

                <span class="help-block tn-mb-0">字母、数字至少6位</span>
            </div>

            <div class="form-group">
                <button type="button" id="changeSubmit" class="btn btn-primary tn-btn-wp">确定</button>
            </div>
        }
    </div>
</div>
<script type="text/javascript">
    require(['jquery', 'tnlayer'], function ($, tnlayer) {
    

    $("#changeSubmit").click(function myfunction() {
        $("#ChangePasswordForm").validate();
        if ($("#ChangePasswordForm").valid()) {
            $.post("@CachedUrlHelper.Action("_ChangePassword", "UserSpace")", $("#ChangePasswordForm").serialize(), function myfunction(data) {
                if (data == 1) {
                    layer.msg("修改成功", {
                        icon: 1
                    });
                    window.setTimeout(function myfunction() {
                        layer.closeAll();
                    }, 2000)

                } else {
                    layer.msg("原密码输入有误", {
                        icon: 2
                    });
                }
            })
        }

    });
    })
</script>
